<? 
session_start();
				
include ('conn.php');
				
$db = get_conn();
				
check_session();
		  
if ($_POST['Agregar']!=""){
	$sql = "INSERT INTO invoices_type (name,code,bank_acc,bank_acc_owner,base_amount) VALUES (
	\"".htmlspecialchars($_POST['name'])."\",
	\"".htmlspecialchars($_POST['code'])."\",
	\"".htmlspecialchars($_POST['bank_acc'])."\",
	\"".htmlspecialchars($_POST['bank_acc_owner'])."\",
	".($_POST['base_amount']).")";
			
	$result = mysql_query($sql);
			
 	if($result){
			
 		do_redirect('../invoices_types.php'); 	  
			
 	}else{
			
 		error_handling('invoices_type.insert  - '.$sql,mysql_error());
			
 	}				  
		 
}//Agregar
		  
if ($_POST['Actualizar']!=""){
			
	$sql = "update invoices_type set 
	name=\"".htmlspecialchars($_POST['name'])."\",
	code=\"".htmlspecialchars($_POST['code'])."\",
	bank_acc=\"".htmlspecialchars($_POST['bank_acc'])."\",
	bank_acc_owner=\"".htmlspecialchars($_POST['bank_acc_owner'])."\",
	base_amount=".$_POST['base_amount']."
 
	where id_it=".$_POST['id_it'];
			 
			
	$result = mysql_query($sql);
			
	if($result){
				
		do_redirect('../invoices_types.php'); 	  
					
			
	}else{
				
		error_handling('invoices_type.update - '.$sql,mysql_error());
			
	}				  
		 
}//update
		  
if ($_POST['Eliminar']!=""){
			
	$sql = "delete from invoices_type where id_it=".$_POST['id_it'];
			
	$result = mysql_query($sql);
			
	if($result){
				
		do_redirect('../invoices_types.php'); 	  
			
	}else{
				
		error_handling('invoices_type.delete - '.$sql,mysql_error());
			
	}				  
		 
}//delete
		  
if ($_POST['Nuevo']!=""){
				
		do_redirect('../invoices_types.php'); 	  
		  
}//nuevo

?>